<?php

class Likes_Model_DbTable_Likes extends Zend_Db_Table_Abstract
{
    protected $_name = 'likes';
	
	
	public function getLikes($commentid){	

		$row = $this->fetchAll("status = 1 AND commentid =".$commentid 	);
    	if (!$row) {
    		throw new Exception("Could not find row");
    	}
    	return $row->toArray();
    }
	
	
	 public function addlike($like_user, $like_tables ,$like_tables_id)
    {
    	$data = array(
    			'like_tables' => $like_tables,
    			'like_tables_id' => $like_tables_id,
    			'like_user' => $like_user,			
				'like_status' =>1			
    	);
		/*
		echo "<pre>";
		print_r($data);
		echo "</pre>";
		exit;
		*/
    	return $this->insert($data);
    }
	
	public function updateStatus($userid, $commentid ,$status)
    {
		$userid = (int)$userid;
		$commentid = (int)$commentid;
    	$data = array(
    			'status' => $status  		
    	);
		
		$this->update($data, "commentid = $commentid AND userid= $userid" );
    }

	 public function detelelike($id)
    {
    	$this->delete('id =' . (int)$id);
		return 1;
    }
}

